# the minimum version of CMake.
cmake_minimum_required(VERSION 3.4.1)
project(ohos_webrtc_demo)

add_definitions(-DOHOS_PLATFORM)
add_definitions(-DWEBRTC_POSIX)
add_definitions(-DWEBRTC_LINUX)
add_definitions(-DWEBRTC_OHOS)
add_definitions(-DOS_POSIX)
add_definitions(-DOS_OHOS)

set(NATIVERENDER_ROOT_PATH ${CMAKE_CURRENT_SOURCE_DIR})
set(WEBRTC_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../../../src)
set(AKI_ROOT_PATH ${CMAKE_CURRENT_LIST_DIR}/../../../oh_modules/@ohos/aki)
set(FFMPEG_LIB_PATH ${WEBRTC_ROOT_PATH}/out/ohos_webrtc)
message(${WEBRTC_ROOT_PATH})
message(${FFMPEG_LIB_PATH})
message(${AKI_ROOT_PATH})

set(CMAKE_MODULE_PATH ${AKI_ROOT_PATH})
find_package(Aki REQUIRED)

include_directories(
    ${WEBRTC_ROOT_PATH}
    ${WEBRTC_ROOT_PATH}/third_party/abseil-cpp
    ${WEBRTC_ROOT_PATH}/third_party/libyuv/include
)

include_directories(${NATIVERENDER_ROOT_PATH}
                    ${NATIVERENDER_ROOT_PATH}/include)
#if(DEFINED PACKAGE_FIND_FILE)
#    include(${PACKAGE_FIND_FILE})
#endif()
add_library(entry SHARED
    napi_init.cpp
)


find_library(
    # Sets the name of the path variable.
    EGL-lib
    # Specifies the name of the NDK library that
    # you want CMake to locate.
    EGL
)

find_library(
    # Sets the name of the path variable.
    GLES-lib
    # Specifies the name of the NDK library that
    # you want CMake to locate.
    GLESv3
)

find_library(
    # Sets the name of the path variable.
    hilog-lib
    # Specifies the name of the NDK library that
    # you want CMake to locate.
    hilog_ndk.z
)

find_library(
    # Sets the name of the path variable.
    libace-lib
    # Specifies the name of the NDK library that
    # you want CMake to locate.
    ace_ndk.z
)

find_library(
    # Sets the name of the path variable.
    libnapi-lib
    # Specifies the name of the NDK library that
    # you want CMake to locate.
    ace_napi.z
)

find_library(
    # Sets the name of the path variable.
    libuv-lib
    # Specifies the name of the NDK library that
    # you want CMake to locate.
    uv
)

find_library(
    ffmpeg_lib
    NAMES ffmpeg
    PATHS ${FFMPEG_LIB_PATH}
    CMAKE_FIND_ROOT_PATH_BOTH
)
target_link_libraries(entry PUBLIC ${ffmpeg_lib})

set(BUILD_RTC_OHOS ON)
add_subdirectory(rtc_client)
target_link_libraries(entry PUBLIC rtc_client)

target_link_libraries(entry PUBLIC Aki::libjsbind)
#target_link_libraries(entry PUBLIC libace_napi.z.so libhilog_ndk.z.so libpixelmap_ndk.z.so libimage_source_ndk.z.so librawfile.z.so)
target_link_libraries(entry PUBLIC
    ${EGL-lib} ${GLES-lib} ${hilog-lib} ${libace-lib} ${libnapi-lib} ${libuv-lib} libnative_window.so libpixelmap_ndk.z.so libimage_source_ndk.z.so librawfile.z.so)